package com.filmoc;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;


public class Main {
	
	public static void main(String[] args){
		User user = new User();
		user.setId(2L);
		user.setFirstname("gucio");
		user.setSurname("Pilus");
		user.setAccesslevel("admin");
		user.setTitle("Mr");

		System.out.println("in main.............................");
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("web");
		EntityManager em = emf.createEntityManager();

		EntityTransaction tx = em.getTransaction();
		try{
		tx.begin();
		em.persist(user);
		tx.commit();
		em.close();
		emf.close();
		}
		catch (Exception ex)
		{
			tx.rollback();
			System.out.println("error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"  + ex);
			
		}
		finally
		{
			
		}
	}

}